#ifndef _CONFIG_MGR_HPP_20120614
#define _CONFIG_MGR_HPP_20120614

#include <string>

#include "base.hpp"

#include "singleton.hpp"
#include "confsvr_cmd.hpp"

using namespace cmd;

struct ConfSvrConf
{
	public :
		CommonConf     _common;

		Host           _service;
	public :
		ConfSvrConf() : _common(), _service() {}

		const std::string to_string() const;
};

typedef SSDBSvrRes        DBSvrConf;
typedef SSBalanceRes      BalanceConf;
typedef SSAccountRes      AccountConf;
typedef SSGatewayRes      GatewayConf;
typedef SSScenceRes       ScenceConf;
typedef SSHttpClientRes   HttpClientConf;

class ConfigMgr : public Singleton<ConfigMgr>
{
	public :
		friend class Singleton<ConfigMgr>;

	public :
		typedef __gnu_cxx::hash_map<uint32_t, DBSvrConf> DBSvrConfMap;
		typedef DBSvrConfMap::iterator DBSvrConfMap_Iter;

		typedef __gnu_cxx::hash_map<uint32_t, GatewayConf> GatewayConfMap;
		typedef GatewayConfMap::iterator GatewayConfMap_Iter;

		typedef __gnu_cxx::hash_map<uint32_t, ScenceConf> ScenceConfMap;
		typedef ScenceConfMap::iterator ScenceConfMap_Iter;

	public :
		int load();

		void display();

	private :
		int load_confsvr(const std::string & pathname);
		int load_dbsvr(const std::string   & pathname);
		int load_balance(const std::string & pathname);
		int load_account(const std::string & pathname);
		int load_gateway(const std::string & pathname);
		int load_scence(const std::string  & pathname);
		int load_http_client(const std::string  & pathname);

	public :
		ConfSvrConf        _confsvr;
		DBSvrConfMap       _dbsvr_map;
		BalanceConf        _balance;
		AccountConf        _account;
		HttpClientConf     _http_client;
		GatewayConfMap     _gateway_map;
		ScenceConfMap      _scence_map;
		
		DECL_LOGGER(logger);
};

#endif

